Skip to content

Handle null Darwin getTitleAsync results without crashing - #1391

Merged
AlexV525 merged 3 commits into
mainfrom
copilot/fix-gettitleasync-null-issue
May 14, 2026
Merged

Handle null Darwin getTitleAsync results without crashing#1391
AlexV525 merged 3 commits into
mainfrom
copilot/fix-gettitleasync-null-issue

Conversation

Copilot AI commented May 14, 2026

Copy link
Copy Markdown
Contributor

PhotoManagerPlugin.getTitleAsync could receive a null result from the Darwin platform channel even though the Dart API returns Future<String>. This change removes the non-null assumption and falls back to an empty string instead.

  • Runtime fix

    • Replace the implicit non-null expectation in getTitleAsync with an inlined null-safe fallback (?? '') for iOS/macOS results.
    • Keep non-Darwin behavior aligned by using the same fallback path for entity.title.
  • Changelog

    • Document the fix under Unreleased.
if (Platform.isIOS || Platform.isMacOS) {
  return await _channel.invokeMethod<String>(
        PMConstants.mGetTitleAsync,
        <String, dynamic>{...},
      ) ??
      '';
}
return entity.title ?? '';

Copilot AI linked an issue May 14, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix getTitleAsync returning null on iOS Handle null Darwin getTitleAsync results without crashing May 14, 2026
Copilot AI requested a review from AlexV525 May 14, 2026 06:26
@AlexV525

Copy link
Copy Markdown
Member

@copilot Remove test and make it inlined.

Copilot AI commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Remove test and make it inlined.

Updated in e0ae2b5: the null fallback is now inlined in getTitleAsync, and the helper-only test was removed.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Dart-side getTitleAsync implementation to avoid crashing when the Darwin platform channel returns null, and records the fix in the changelog.

Changes:

  • Uses invokeMethod<String> and falls back to '' for null Darwin title results.
  • Keeps non-Darwin fallback behavior returning entity.title ?? ''.
  • Adds an Unreleased changelog entry for the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/src/internal/plugin.dart Adds null-safe fallback for Darwin getTitleAsync channel results.
CHANGELOG.md Documents the Darwin getTitleAsync null-result fix under Unreleased fixes.

Comment thread lib/src/internal/plugin.dart
@AlexV525
AlexV525 marked this pull request as ready for review May 14, 2026 08:45
@AlexV525
AlexV525 requested a review from CaiJingLong as a code owner May 14, 2026 08:45
@github-actions

Copy link
Copy Markdown

Download apk from here for ab0538b

@AlexV525
AlexV525 merged commit d0240e9 into main May 14, 2026
17 checks passed
@AlexV525
AlexV525 deleted the copilot/fix-gettitleasync-null-issue branch May 14, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug report] getTitleAsync returns null on iOS

3 participants